﻿//***********************************************************************
// Assembly         : phpmk
// Author           : sy
// Created          : 06-14-2010
//
// Last Modified By : sy
// Last Modified On : 06-14-2010
// Description      : 
//
// Copyright        : (c) Another-D-Mention Software. All rights reserved.
//***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace phpmk.ADM.Core.Model
{
    public class DataModel
    {
        public bool runInTestMode = false;
        [Configurable]
        public Profile Profile = new Profile();
        [Configurable("Build task. Required")]
        public Build Build = new Build();
        [Configurable("Deploy tasks list. Optional")]
        public Deploy Deploy = new Deploy();
    }

    public class Deploy
    {
        [Configurable]
        public Env[] Env = new Env[1] { new Env() };
    }

    public class Profile
    {
        [Configurable("Project name. Required", "My PHP Project")]
        public string Name;
        [Configurable("Project Version. Required\nRelease number and build number will be incremented on each completed task", "1.0.0.0")]
        public string Version;
        [Configurable("Project Description. Optional", "Brief project description")]
        public string Description;
    }

    public class Build
    {
        [Configurable("Build target. Builds the installer for a specific deploy enviroment", "dev")]
        public string Target;
        [Configurable("Place to store the install volumes. Default is /build/. Optional", "build")]
        public string BuildLocation;
        [Configurable("Installer name. Default is setup. Optional\nWill be used as filename: setup.php or setup_01.php for volumes", "setup")]
        public string InstallerName;
        [Configurable("Use multiple volumes. Default true. Optional", "true")]
        public string UseMultipleVolumes;
        [Configurable("Make setup file self delete after instalation. Default is true. Optional", "true")]
        public string SelfDeleteInstaller;

        [Configurable("List of assets that shouldn't be included in the installer archive\n.svn folders, this file and the buildPath folder are ignored by default")]
        public IgnoreList Ignore = new IgnoreList();

        [Configurable("Windows command line actions to be executed before the build")]
        public ActionItem[] PreActions = new ActionItem[1]{ new ActionItem() };
        [Configurable("Windows command line actions to be executed after the build")]
        public ActionItem[] PostActions = new ActionItem[1] { new ActionItem() };
    }

    public class IgnoreList
    {
        [Configurable("List of folders that shouldn't be included in the installer archive")]
        public FolderItem[] Folders = new FolderItem[1]{ new FolderItem() };
        [Configurable("List of files that shouldn't be included in the installer archive")]
        public FileItem[] Files = new FileItem[1]{ new FileItem() };
    }

    public class FileItem
    {
        [Configurable(""," ")]
        public string File;
    }

    public class FolderItem
    {
        [Configurable(""," ")]
        public string Folder;
    }

    public class ActionItem
    {
        [Configurable(""," ")]
        public String Action;
    }

    public class Env
    {
        [Configurable("", "dev", true)]
        public string Name;
        [Configurable("Required to call the install script after uploading to ftp", "http://dev.localhost/project/")]
        public string TargetURL;

        [Configurable("if you don't feel like providing passwords in this file, remove the password attribute and you will be asked for the password at build time")]
        public FTP Ftp = new FTP();
         [Configurable("if you don't feel like providing passwords in this file, remove the password attribute and you will be asked for the password at build time")]
        public MySQL Mysql = new MySQL();
    }

    public class FTP
    {
        [Configurable("", "localhost", true)]
        public string Host;
        [Configurable("", "21", true)]
        public string Port;
        [Configurable("", "anonymous", true)]
        public string Username;
        [Configurable("", "email@domain.com", true)]
        public string Password;
        [Configurable("", "public_html", true)]
        public string Remotepath;

        [Configurable("Pre deploy ftp commands to execute")]
        public ActionItem[] PreActions = new ActionItem[1]{ new ActionItem() };
        [Configurable("Post deploy ftp commands to execute")]
        public ActionItem[] PostActions = new ActionItem[1] { new ActionItem() };
    }

    public class MySQL
    {
        [Configurable("", "localhost", true)]
        public string Host;
        [Configurable("", "3306", true)]
        public string Port;
        [Configurable("", "root", true)]
        public string Username;
        [Configurable("", "", true)]
        public string Password;
        [Configurable("", "test", true)]
        public string Database;

        [Configurable("Install MySQL script. Export from PhpMyAdmin. MySQL conectivity details must be provided", "install.sql")]
        public string InstallScript;
        [Configurable("Update MySQL script. Used if tables from install script already exists. Optional.", "update.sql")]
        public string UpdateStcript;
    }
}
